<?php


namespace app\shop\controller;


use app\BaseController;
use app\enterprise\model\Friend;
use app\enterprise\model\Message;
use app\shop\common\consts\Consts;
use app\shop\model\chat\GroupUserModel;
use app\shop\model\order\OrderModel;
use app\shop\model\user\ChatUserModel;
use app\shop\model\user\MessageModel;
use app\shop\model\user\UserModel;
use app\shop\service\config\ConfigService;
use app\shop\service\until\OssService;
use app\shop\service\user\UserService;
use easyTask\Terminal;

use GatewayClient\Gateway;
use think\facade\Config;
use think\facade\Db;
use think\facade\Log;
use think\Session;


class IndexController extends BaseController
{
    function index111(Session $session)
    {
        try {

            return $this->success();
        } catch (\Exception $exception) {
            return $this->error($exception->getMessage());
        }
    }

    protected function verifyCaptcha(...$args)
    {
        list($a, $b, $c) = $args;
    }

    function index1()
    {
        try {
            $userId = 397;
            Gateway::$registerAddress = config('gateway.registerAddress');
            $clientIdArr = Gateway::getClientIdByUid($userId);

            $chatSignArr = GroupUserModel::where('user_id', $userId)->column('chat_sign');
            if (!$chatSignArr) {
                return true;
            }
            foreach ($chatSignArr as $chatSign) {
                \GatewayWorker\Lib\Gateway::joinGroup($client_id, $chatSign);
            }
            return $this->success($clientIdArr);
        } catch (\Exception $exception) {
            return $this->error($exception->getMessage());
        }
    }
}